
#ifndef etl_server_socket_h
#define etl_server_socket_h

#include "etl_socket.h"
#include "etl_connection_base.h"
#include "etl_list.h"

namespace etl
{

class etl_server_socket
{
public:
    etl_server_socket();
    virtual ~etl_server_socket();

    int set_port( int p );
    int attach_connection_prototype( etl::etl_connection_base* proto );

    int start();
    int stop();

    int get_sok_id();

private:
    etl_server_socket(const etl_server_socket& obj);
    etl_server_socket& operator =(const etl_server_socket& obj);
    
    int prune_old_connections();
    
    static void* connection_launcher(void* arg);
    
    etl::etl_socket server_sok;
    etl::etl_connection_base* prototype;
    int port;
    etl::etl_list<etl::etl_connection_base*> active_connections;
    bool started;
};

}

#endif
